package com.lynx.core.util;

import java.io.IOException;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
/**
 * 
 * @author lxp
 *
 */
public class ExtractParamUtil {
	
	public static Map<String, String> getParams(HttpServletRequest req) throws IOException{
		Map<String, String> result = new HashMap<String, String>();
		Enumeration<?> enumerations =   req.getParameterNames();
		while (enumerations.hasMoreElements()) {
			String name = (String)enumerations.nextElement();
			String val = req.getParameter(name);
			result.put(name, val);
		}
		return result;
	}
	public static Map<String, String[]> getParamStrs(HttpServletRequest req) throws IOException{
		Map<String, String[]> result = new HashMap<String, String[]>();
		Enumeration<?> enumerations =   req.getParameterNames();
		while (enumerations.hasMoreElements()) {
			String name = (String)enumerations.nextElement();
			String[] val = req.getParameterValues(name);
			if (val!=null&&val.length>0) {
				result.put(name, val);
			}
		}
		return result;
	}

}
